package com.wedimob.html;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class FormField {
	private FormFieldType type;
	private String name;
	private List<String> values = new ArrayList<String>();
	private Map<String, String> selectValues = new HashMap<String, String>();

	public FormField(FormFieldType type, String name, String value) {
		super();
		this.type = type;
		this.name = name;
		this.values.add(value);
	}

	public void addSelectValue(String key, String label) {
		if (type != FormFieldType.SELECT)
			throw new RuntimeException("Try to add ");

		selectValues.put(key, label);
	}

	public void addValue(String value) {
		values.add(value);
	}

	public void clearValues() {
		values.clear();
	}

	public void setValue(String value) {
		clearValues();
		addValue(value);
	}

	public String getValue() {
		return values.get(0);
	}

	public FormFieldType getType() {
		return type;
	}

	public String getName() {
		return name;
	}

	public List<String> getValues() {
		return values;
	}

	public Map<String, String> getSelectValues() {
		return selectValues;
	}

}
